import request from '@/utils/request_app'

// 获取二维码
export function GetCode(data) {
  return request({
    url: 'app/login/code',
    method: 'post',
    data,
    headers: {
      isToken: false,
    },
  })
}

// 获取用户登录信息
export function getUserInfo(params) {
  return request({
    url: 'app/user/info',
    method: 'get',
    data: params,
  })
}

//登录
export function EwmCodeLogin(userName, code) {
  const data = {
    userName,
    code,
  }
  return request({
    url: 'app/login/phone',
    headers: {
      isToken: false,
    },
    method: 'post',
    data: data,
  })
}

//登出
export function Loginout() {
  return request({
    url: 'app/login/out',
    method: 'get',
  })
}

//一键登录
export function quickLoginApi(params) {
  const data = {
    openId: params.openId,
    accessToken: params.accessToken,
  }
  return request({
    url: 'app/login/quickLogin',
    headers: {
      isToken: false,
    },
    method: 'post',
    data: data,
  })
}

//获取IM签名接口
export function getIMUserSigApi(data) {
  console.log('获取IM签名接口')
  return request({
    url: 'app/im/userSig',
    method: 'get',
    params: data,
  })
}

//更换手机号
export const changePhone = data => {
  return request({
    url: `app/login/changePhone`,
    method: 'post',
    data: data,
  })
}
